Skip to content

Bug Fix: improve Kiuwan SCA parser to support multi component findings #12753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: bugfix
Choose a base branch
from

Conversation

mwager
Copy link
Contributor

@mwager mwager commented Jul 7, 2025

This PR enhances the Kiuwan SCA Parser by modifying the logic to create one finding per component, instead of taking only the first component from the components array.

The buggy code:

grafik

Motivation

In the current implementation, for a given CVE from a Kiuwan SCA scan, only the first component listed is used to create a finding. However, many CVEs in Kiuwan are related to multiple components. This leads to loss of detail and incomplete representation of risks in DefectDojo.

Test results

  • Manual test with real-world Kiuwan JSON input shows that all findings are now preserved and properly associated with the correct component.

This checklist is for your information.

  • Bugfixes should be submitted against the bugfix branch.
  • Give a meaningful name to your PR, as it may end up being used in the release notes.
  • Your code is flake8 compliant.
  • Your code is python 3.11 compliant.
  • Add applicable tests to the unit tests.
  • Add the proper label to categorize your PR.

@mwager mwager requested review from Maffooch and mtesauro as code owners July 7, 2025 13:09
@github-actions github-actions bot added the parser label Jul 7, 2025
Copy link

dryrunsecurity bot commented Jul 7, 2025

DryRun Security

No security concerns detected in this pull request.


All finding details can be found in the DryRun Security Dashboard.

@mwager
Copy link
Contributor Author

mwager commented Jul 7, 2025

TODO: Ideally you extend the test suite in tests/ and dojo/unittests to cover the changed in this PR.

I will soon check how to update & run unit tests, any info/docs on it appreciated :)

@valentijnscholten
Copy link
Member

Thanks for looking into this, information on running unit tests: https://github.com/DefectDojo/django-DefectDojo/blob/master/readme-docs/DOCKER.md#run-the-tests-with-docker-compose

Copy link
Contributor

@Maffooch Maffooch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@valentijnscholten what do you think of this approach?

# We want one unique finding in DD for each component affected:
for component in components:
finding = Finding(test=test)
finding.unique_id_from_tool = f"{row['cve']}|{component.get('artifact')}|{component.get('version')}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constructing the unique_id_from_tool is not something that is generally done. The intention is that the field is created from the tool.

This parser in particular uses the DEDUPE_ALGO_HASH_CODE, so I think the unique_id_from_tool should be omitted. This could be an issue for folks that updated the default hash code fields to use unique_id_from_tool, so we should also include something in the release notes to indicate the change

Here is the current dedupe settings:

"Kiuwan SCA Scan": ["description", "severity", "component_name", "component_version", "cwe"],

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually Kiuwan provides a unique id, this was just a test on our side. I will run one more test later this week and maybe change this back. This PR should be about the components issue only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed changes back to old logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants